<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateChatGroupUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('chat_group_users', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('groupId')->default(0)->comment('群聊id');
            $table->unsignedInteger('shopId')->default(0)->comment('门店id');
            $table->unsignedInteger('userId')->default(0)->comment('用户id');
            $table->tinyInteger('role')->default(0)->comment('角色 1总部 2老板 3员工');
            $table->string('alias', 32)->default('')->comment('花名（固定显示的名称）');
            $table->string('avatar', 256)->default('')->comment('头像');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->tinyInteger('isDeleted')->default(0)->comment('是否删除 0否 1是');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '群聊 - 关联用户';

            $table->index(['groupId'], 'idx_groupId');
            $table->index(['shopId'], 'idx_shopId');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('chat_group_users');
    }
}
